Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault in the Breadcrumb system when associated model is unloaded #454

Merged
merged 8 commits into from
Nov 11, 2020

Conversation

azeey
Copy link
Contributor

@azeey azeey commented Nov 10, 2020

Currently, when a model is unloaded, the model systems associated with that model do not get unloaded. If the systems then try to access the components of the model, they will fail. However, most systems check the validity of the model they are associated with in the System::Configure function and assume that if the model is valid then, it will be valid in PreUpdate/PostUpdate functions. I think it would be nice for that assumption to hold, but right now it might not.

In the case of the Breadcrumb system, the system retrieves the pose of the model at every time step in PreUpdate and assumes that it will be valid. However, if the model is unloaded, the Pose component will be a nullptr causing a segfault.

The ideal fix would be to make sure systems are unloaded when the model gets unloaded (see #113), but until then, this PR adds a check for the validity of the model in Breadcrumbs::PreUpdate.

The segfault occurs when a model containing a Breadcrumbs system gets
unloaded by the level manager. Since systems don't get unloaded, the
Breadcrumbs system continues to operate assuming that the model it is
associated with is valid.

Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
@azeey azeey requested a review from caguero November 10, 2020 21:51
@azeey azeey self-assigned this Nov 10, 2020
@github-actions github-actions bot added the 📜 blueprint Ignition Blueprint label Nov 10, 2020
@azeey azeey added the bug Something isn't working label Nov 10, 2020
@azeey
Copy link
Contributor Author

azeey commented Nov 10, 2020

Failing tests are fixed by #455

@@ -547,6 +550,123 @@ TEST_F(BreadcrumbsTest, AllowRenaming)
EXPECT_TRUE(this->server->HasEntity("B1_0_1"));
}

/////////////////////////////////////////////////
/// Return a list of model entities whose names match the given regex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be eventually useful to move to EntityComponentManager. The trick is that it's probably too slow, and users may not realize that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can probably make it generic enough that it would work with any entity that has a name component.

src/systems/breadcrumbs/Breadcrumbs.cc Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 11, 2020

Codecov Report

Merging #454 (d987dd8) into ign-gazebo2 (65fd2dc) will increase coverage by 0.15%.
The diff coverage is 50.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           ign-gazebo2     #454      +/-   ##
===============================================
+ Coverage        77.88%   78.04%   +0.15%     
===============================================
  Files              187      187              
  Lines            10208    10214       +6     
===============================================
+ Hits              7951     7972      +21     
+ Misses            2257     2242      -15     
Impacted Files Coverage Δ
src/systems/breadcrumbs/Breadcrumbs.cc 87.35% <50.00%> (-1.34%) ⬇️
src/systems/physics/Physics.cc 75.00% <0.00%> (+0.88%) ⬆️
src/SimulationRunner.cc 96.39% <0.00%> (+2.40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65fd2dc...d987dd8. Read the comment docs.

@chapulina chapulina merged commit 327cde7 into ign-gazebo2 Nov 11, 2020
@chapulina chapulina deleted the breadcrumb_check_model branch November 11, 2020 01:44
doisyg pushed a commit to wyca-robotics/ign-gazebo that referenced this pull request Dec 13, 2020
…ed (gazebosim#454)

The segfault occurs when a model containing a Breadcrumbs system gets
unloaded by the level manager. Since systems don't get unloaded, the
Breadcrumbs system continues to operate assuming that the model it is
associated with is valid.

Signed-off-by: Addisu Z. Taddese <[email protected]>
Signed-off-by: Guillaume Doisy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📜 blueprint Ignition Blueprint bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants